﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SalePartial.IDAL;
using System.Data.SqlClient;
using SalePartial.Model;

namespace SalePartial.BLL
{
    public class XPCompanyCert : IXPCompanyCert
    {
        private IXPCompanyCert dal = SalePartial.DALFactory.DataAccess.CreateXPCompanyCert();


        //public void Create()
        //{
        //    XPCompanyCertUtility.Insert(this.CertID, this.CompanyID, this.CertType, this.CertName, this.CertFileName, this.CertFileContentType, this.CertFileSize, this.CertFileData, this.CreateUserID, this.CreateDate,
        //    this.LastUpdateDate, this.ModerateUserID, this.ModerateStatus, this.ModerateDate, this.Comments);
        //}

        public void Delete(XPCompanyCertInfo info)
        {
            this.Delete(info.CertID);
        }

        public XPCompanyCertInfo GetXPCompanyCert(Guid id)
        {
            SqlDataReader reader = this.SelectReader(id);
            if (reader.Read())
            {
                XPCompanyCertInfo info = new XPCompanyCertInfo(reader);
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
                return info;
            }
            return null;

        }

        //public void Update()
        //{
        //    XPCompanyCertUtility.Update(this.CertID, this.CompanyID, this.CertType, this.CertName, this.CertFileName, this.CertFileContentType, this.CertFileSize, this.CertFileData, this.CreateUserID, this.CreateDate,
        //    this.LastUpdateDate, this.ModerateUserID, this.ModerateStatus, this.ModerateDate, this.Comments);
        //}


        public int Delete(Guid CertID)
        {
           return dal.Delete(CertID);
        }

        public int DeleteByCompanyID(Guid CompanyID)
        {
            return dal.DeleteByCompanyID(CompanyID);
        }

        public int DeleteByCreateUserID(Guid CreateUserID)
        {
            return dal.DeleteByCreateUserID(CreateUserID);
        }

        public int DeleteDynamic(string v_whereCondition)
        {
            return dal.DeleteDynamic(v_whereCondition);
        }

        public int Insert(XPCompanyCertInfo info)
        {
            return dal.Insert(info);
        }

        public System.Data.DataSet SelectAll()
        {
            return dal.SelectAll();
        }

        public System.Data.DataSet SelectByCompanyID(Guid CompanyID)
        {
            return dal.SelectByCompanyID(CompanyID);
        }


        public List<XPCompanyCertInfo> SelectInfoByCompanyID(Guid CompanyID)
        {
            SqlDataReader reader = this.SelectReaderByCompanyID(CompanyID);
            List<XPCompanyCertInfo> infoList = new List<XPCompanyCertInfo>();
            while (reader.Read())
            {
                XPCompanyCertInfo info = new XPCompanyCertInfo(reader);
                infoList.Add(info);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return infoList;

        }
        public System.Data.DataSet SelectByCreateUserID(Guid CreateUserID)
        {
            return dal.SelectByCreateUserID(CreateUserID);
        }

        public System.Data.DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
        {
            return dal.SelectDynamic(v_whereCondition, v_orderByExpression);
        }

        public System.Data.DataSet SelectPaged()
        {
            return dal.SelectPaged();
        }

        public System.Data.SqlClient.SqlDataReader SelectReader(Guid CertID)
        {
            return dal.SelectReader(CertID);
        }

        public System.Data.SqlClient.SqlDataReader SelectReaderByCompanyID(Guid CompanyID)
        {
            return dal.SelectReaderByCompanyID(CompanyID);
        }

        public System.Data.SqlClient.SqlDataReader SelectReaderByCreateUserID(Guid CreateUserID)
        {
            return dal.SelectReaderByCreateUserID(CreateUserID);
        }

        public System.Data.DataSet SelectSingle(Guid CertID)
        {
            return dal.SelectSingle(CertID);
        }

        public int Update(XPCompanyCertInfo info)
        {
            return dal.Update(info);
        }
    }
}
